import request from '../utils/request'

const getArticleDetailAPI = ({ artId }) => {
    return request({
        method: 'GET',
        url: `/v1_0/articles/${artId}`
    })
}

// 文章页 - 关注作者
const followAutAPI = ({ autId }) => {
    return request({
        method: 'POST',
        url: '/v1_0/user/followings',
        data: {
            target: autId
        }
    })
}


// 文章页 - 取关作者
const UnfollowAutAPI = ({ autId }) => {
    return request({
        method: 'DELETE',
        url: `/v1_0/user/followings/${autId}`,
    })
}

// 文章页 - 喜欢
const likeArtAPI = ({ artId }) => {
    return request({
        method: 'POST',
        url: '/v1_0/article/likings',
        data: {
            target: artId
        }
    })
}

// 文章页 - 不喜欢
const dislikeArtAPI = ({ artId }) => {
    return request({
        method: 'DELETE',
        url: `/v1_0/article/likings/${artId}`,
    })
}


// 文章页 - 获取评论列表
const getCommentAPI = ({ artId, offset, limit = 10 }) => {
    return request({
        method: 'GET',
        url: '/v1_0/comments',
        params: {
            type: 'a',
            source: artId,
            offset,
            limit
        }
    })
}

// 文章页 - 评论点赞
const likeCommentAPI = ({ cmtId }) => {
    return request({
        method: 'POST',
        url: '/v1_0/comment/likings',
        data: {
            target: cmtId
        }
    })
}

// 文章页 - 评论不点赞
const dislikeCommentAPI = ({ comId }) => {
    return request({
        method: 'DELETE',
        url: `/v1_0/comment/likings/${comId}`
    })
}

// 文章页 - 发布评论
const publishCmtAPI = ({ artId, data }) => {
    return request({
        method: 'POST',
        url: '/v1_0/comments',
        data: {
            target: artId,
            content: data
        }
    })
}
export {
    getArticleDetailAPI,
    followAutAPI,
    UnfollowAutAPI,
    likeArtAPI,
    dislikeArtAPI,
    getCommentAPI,
    likeCommentAPI,
    dislikeCommentAPI,
    publishCmtAPI
}